package com.ruoyi.generation3.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.generation3.domain.StationAreaManagementGeneration3;
import com.ruoyi.generation3.service.IStationAreaManagementGeneration3Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 驻场片区3代码Controller
 * 
 * @author ruoyi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/generation3/generation3")
public class StationAreaManagementGeneration3Controller extends BaseController
{
    @Autowired
    private IStationAreaManagementGeneration3Service stationAreaManagementGeneration3Service;

    /**
     * 查询驻场片区3代码列表
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationAreaManagementGeneration3 stationAreaManagementGeneration3)
    {
        startPage();
        List<StationAreaManagementGeneration3> list = stationAreaManagementGeneration3Service.selectStationAreaManagementGeneration3List(stationAreaManagementGeneration3);
        return getDataTable(list);
    }

    /**
     * 导出驻场片区3代码列表
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:export')")
    @Log(title = "驻场片区3代码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationAreaManagementGeneration3 stationAreaManagementGeneration3)
    {
        List<StationAreaManagementGeneration3> list = stationAreaManagementGeneration3Service.selectStationAreaManagementGeneration3List(stationAreaManagementGeneration3);
        ExcelUtil<StationAreaManagementGeneration3> util = new ExcelUtil<StationAreaManagementGeneration3>(StationAreaManagementGeneration3.class);
        util.exportExcel(response, list, "驻场片区3代码数据");
    }

    /**
     * 获取驻场片区3代码详细信息
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stationAreaManagementGeneration3Service.selectStationAreaManagementGeneration3ById(id));
    }

    /**
     * 新增驻场片区3代码
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:add')")
    @Log(title = "驻场片区3代码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StationAreaManagementGeneration3 stationAreaManagementGeneration3)
    {
        return toAjax(stationAreaManagementGeneration3Service.insertStationAreaManagementGeneration3(stationAreaManagementGeneration3));
    }

    /**
     * 修改驻场片区3代码
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:edit')")
    @Log(title = "驻场片区3代码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationAreaManagementGeneration3 stationAreaManagementGeneration3)
    {
        return toAjax(stationAreaManagementGeneration3Service.updateStationAreaManagementGeneration3(stationAreaManagementGeneration3));
    }

    /**
     * 删除驻场片区3代码
     */
    @PreAuthorize("@ss.hasPermi('generation3:generation3:remove')")
    @Log(title = "驻场片区3代码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stationAreaManagementGeneration3Service.deleteStationAreaManagementGeneration3ByIds(ids));
    }

    //    获取片区 GetAreaName

    @PreAuthorize("@ss.hasPermi('generation3:generation3:query')")
    @GetMapping(value = "/GetAreaName")
    public AjaxResult GetAreaName()
    {
        return success(stationAreaManagementGeneration3Service.selectAreaNameGeneration3());
    }

//    获取地区 GetLocation

    @PreAuthorize("@ss.hasPermi('generation3:generation3:query')")
    @GetMapping(value = "/GetLocation")
    public AjaxResult GetLocation()
    {
        System.out.println("进入控制器");
        return success(stationAreaManagementGeneration3Service.selectGetLocationGeneration3());
    }

}
